package com.egao.orderB.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.orderB.mapper.DriverMaintainMapper;
import com.egao.orderB.entity.DriverMaintain;
import com.egao.orderB.service.DriverMaintainService;
import org.springframework.stereotype.Service;
import com.egao.orderB.biz.DriverMaintainBiz;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
//import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 日常维护服务实现类
 * @author : Doman
 * @date : 2021-05-28 16:37:15
 * @version ：1.0
 */
@Service
public class DriverMaintainServiceImpl /*extends ServiceImpl<DriverMaintainMapper, DriverMaintain> */implements DriverMaintainService {

	@Autowired
	private DriverMaintainBiz driverMaintainBiz;

    /**
    @Override
    public PageResult<DriverMaintain> listPage(PageParam<DriverMaintain> page) {
        List<DriverMaintain> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<DriverMaintain> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, DriverMaintain driverMaintain, User loginUser)  throws Exception{
        return driverMaintainBiz.list(page,driverMaintain,loginUser);
    }

    @Override
    public JsonResult list(DriverMaintain driverMaintain, User loginUser) {
        return JsonResult.ok().setData(driverMaintainBiz.list(driverMaintain,loginUser));
    }

    @Override
    public JsonResult getById(DriverMaintain driverMaintain) {
        return JsonResult.ok().setData(driverMaintainBiz.getById(driverMaintain));
    }

    @Transactional
    @Override
    public JsonResult save(DriverMaintain driverMaintain, User loginUser) {
        if (driverMaintainBiz.save(driverMaintain, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(DriverMaintain driverMaintain, User loginUser) {
        if (driverMaintainBiz.update(driverMaintain, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(DriverMaintain driverMaintain, User loginUser) {
        if (driverMaintainBiz.remove(driverMaintain, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
